home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / GRAHAM / XA_6S.ZIP / SOURCE / WATCHBOX.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-14  |  2.1 KB  |  84 lines

  1. /*
  2.  * XaAES - XaAES Ain't the AES
  3.  *
  4.  * A multitasking AES replacement for MiNT
  5.  *
  6.  */
  7.  
  8. #include <VDI.H>
  9. #include "XA_DEFS.H"
  10. #include "XA_TYPES.H"
  11. #include "XA_GLOBL.H"
  12. #include "K_DEFS.H"
  13. #include "OBJECTS.H"
  14.  
  15. /*
  16.     This routine behaves a lot like graf_watchbox() - in fact, XaAES's
  17.     graf_watchbox calls this.
  18.     
  19.     The differance here is that we handle colour icons properly (something
  20.     that AES4.1 didn't do).
  21.     
  22.     I've re-used this bit from the WINDIAL module I wrote for the DULIB GEM library.
  23.     
  24.     This routine assumes that any clipping is going to be done elsewhere before we get
  25.     to here.
  26. */
  27. short watch_object(OBJECT *dial, short ob, short in_state, short out_state)
  28. {
  29.     OBJECT *the_object=dial+ob;
  30.     short pobf=-2,obf=ob,mx,my,mb,x,y,w,h,omx,omy;
  31.     
  32.     vq_mouse(V_handle,&mb,&omx,&omy);
  33.     
  34.     object_abs_coords(dial, ob, &x, &y);    /* call XaAES's internal objc_offset() */
  35.     w=the_object->ob_width+2;
  36.     h=the_object->ob_height+2;
  37.     x--; y--;
  38.  
  39.     if (!mb)        /* If mouse button is already released, assume that was just a click, so select */
  40.     {
  41.         (dial+ob)->ob_state=in_state;
  42.         v_hide_c(V_handle);
  43.         display_object(dial,ob,x-the_object->ob_x+1,y-the_object->ob_y+1);
  44.         v_show_c(V_handle,1);
  45.     }else{
  46.     
  47.         while (mb)        /* This loop contains a pretty busy wait, but I don't think it's to */
  48.         {                /* much of a problem as the user is interacting with it continuously. */
  49.             vq_mouse(V_handle,&mb,&mx,&my);
  50.         
  51.             if ((mx!=omx)||(my!=omy))
  52.             {
  53.                 omx=mx; omy=my;
  54.                 obf=find_object(dial, ob, 10, mx, my);
  55.         
  56.                 if (obf==ob)
  57.                     (dial+ob)->ob_state=in_state;
  58.                 else
  59.                     (dial+ob)->ob_state=out_state;
  60.                 
  61.                 if (pobf!=obf)
  62.                 {
  63.                     pobf=obf;
  64.                     v_hide_c(V_handle);        
  65.                     display_object(dial,ob,x-the_object->ob_x+1,y-the_object->ob_y+1);
  66.                     v_show_c(V_handle,1);
  67.                 }
  68.             }
  69.         }
  70.         
  71.     }
  72.  
  73.     vst_alignment(V_handle,0,5,&x,&x);
  74.     vsf_interior(V_handle,FIS_SOLID);
  75.     vswr_mode(V_handle, MD_TRANS);
  76.     vst_font(V_handle,display.standard_font_id);
  77.     vst_point(V_handle,display.standard_font_point,&x,&x,&x,&x);
  78.  
  79.     if (obf==ob)
  80.         return 1;
  81.     else
  82.         return 0;
  83. }
  84.